{extend name="public:index"/} {block name="title"}{:sysconf('title')}{/block} {block name="content"}
<section class="ncbj_sellerlist">
    <div class="searchbox">
        <div class="fhbox">
            <div class="fhle">
                <a href="javascript:history.back(-1)"></a>
            </div>
            <form action="{:url('Index/search')}">
                <div class="search">
                    <p class="left"><input name="keywords" class="sous" placeholder="关键字" style="outline:none"></p>
                    <p class="right">
                        <button></button>
                    </p>
                </div>
            </form>
        </div>
    </div>
    <div style="height:2rem;"></div>
    <div class="caipromain">
        {if condition="$list"}
        <ul id="goods_jiazai">
            {volist name="list" id="vo"}
            <li class="caip">
                <a href="{:url('Goods/show',['id'=>$vo['id']])}">
                    <p class="p"><img src="{$vo.img_url}" alt=""></p>
                    <b>{$vo.title}</b>
                    <p class="p2"><em>{$vo.sell_price}元</em><i>{$vo.market_price}元</i></p>
                </a>
            </li>
            {/volist}
        </ul>
        {else/}
        <div class="nofind"><img src="__INDEX__/images/nosp.png" alt="">
            <p>暂时没有商品</p>
        </div>
        {/if}
        <div class="jiazai" style="display: none;">
            <em></em>
            <p id="tishi_img"><img src="__INDEX__/images/loding.gif" alt=""></p>
            <p id="tishi">努力加载中</p>
        </div>
    </div>
</section>

<script>
    var daodi = 0;
    var page = 1;
    var http = window.location.host;
    $(window).scroll(
        function() {
            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();
            if ((scrollHeight - scrollTop - windowHeight) == 0) {
                if (daodi == 1) {
                    return false;
                }
                $('.jiazai').show();
                $.ajax({
                    url: "{:url('search')}",
                    type: 'post',
                    async: 'false',
                    data: {
                        'page': page,
                        'keywords': "{:input('get.keywords')}"
                    },
                    dataType: 'json',
                    success: function(res) {
                        if (res.code == 0) {
                            page = page + 1;
                            var str = '';
                            $.each(res.data, function(i, item) {
                                str += "<li class='caip'><a href='http://" + http + "/Index/Goods/show/id/" + item.id + "'><p class='p'><img src='" + item.img_url + "'alt=''></p><b>" + item.title + "</b><p class='p2'><em>" + item.sell_price + "元</em><i>" + item.market_price + "元</i></p></a></li>";
                            })
                            $('#goods_jiazai').append(str);
                        } else {
                            daodi = 1;
                            $('#tishi_img').hide();
                            $('#tishi').html('没有更过数据!');
                        }
                    }
                });

            }
        }
    )
</script>
{/block}